package com.wx.mapper;

import com.wx.entity.Notice;
import com.wx.vo.NoticeVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface NoticeMapper {

    /*新增通知*/
    @Insert("insert into notice(title, content, update_user, update_time, username, is_confirm) " +
            "values (#{title},#{content},#{updateUser},#{updateTime},#{username},#{isConfirm})")
    void setnotice(Notice notice);

    /*根据用户名查询通知*/
    @Select("select * from notice where username=#{username} and is_confirm=0")
    List<NoticeVO> getNoticeByUsername(Notice notice);


    /*用户收到通知*/
    @Update("update notice set is_confirm = 1 where id = #{id}")
    void receiveNotice(Notice notice);
}
